/**
 * @author      CPT 236 - 001
 *
 * @version     1.0 Final (maybe)
 */

package battleship.gui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
* Primary 'Game Over' GUI code.
*
* This Class sets up the GUI for the 'Game Over' menu that is displayed
* after the user completes a game (win or lose).
*/

public class GameOverMenu extends JFrame implements ActionListener{
	private JButton newGame = new JButton("New Game");
	private JButton quit = new JButton("Quit");
	
    /**
		* Sets up the actual GUI and creates two buttons: 'New Game' and 'Quit'.
		*/
      
	public GameOverMenu(String v) {
		super("Battleship: Game Over");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(350, 100);
		setVisible(true);
		
		JLabel victorLabel = new JLabel(v + " won!");
		JPanel labelPanel = new JPanel();
		labelPanel.add(victorLabel);
		add(labelPanel, BorderLayout.PAGE_START);
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.add(newGame);
		buttonPanel.add(quit);
		add(buttonPanel, BorderLayout.PAGE_END);
		
		newGame.addActionListener(this);
		quit.addActionListener(new Quit());
	}
   
 	/**
		* Listener for 'New Game' button.
		*/  
	public void actionPerformed(ActionEvent aE){
		NewGame();
	}
	
	  /**
		* Listener for 'Quit' button.
		*/
	class Quit implements ActionListener{
		public void actionPerformed(ActionEvent aE){
			Quit();
		}
	}
	
   /**
		* The method for the 'New Game' button wich does what its name infers.
		*/
	public void NewGame(){
		new GamePlay();
		setVisible(false);
	}
	
   /**
		* Method for the 'Quit' which, again does what its name infers.
		*/
	public void Quit(){
		System.exit(0); //Test Code
	}
}
	